#include <stdexcept>

#include "HashTableIterator.h"
#include "HashTable.h"

HashTableIterator::HashTableIterator(HashTable& table):
        currentIndex(0),
        table(table)
{
    table.getKeys(tableKeys);
    keysSize = table.getSize();
}
        
bool HashTableIterator::hasCurrent()
{
    return currentIndex < keysSize;
}

void HashTableIterator::next()
{
    if(!hasCurrent())
        throw std::out_of_range("Ya se alcanzó el final en el iterador");
    else
        ++currentIndex;
}

ICollectible *HashTableIterator::getCurrent()
{
    return table.get(tableKeys[currentIndex]);
}

HashTableIterator::~HashTableIterator()
{
    delete[] tableKeys;
}


